#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int h1, m1, s1, h2, m2, s2;
		cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
		int ans1 = 0;
		int ans2 = 0;
		int ans3 = 0;
		ans1 = (h1 * 60 * 60 + m1 * 60 + s1+ h2 * 60 * 60 + m2 * 60 + s2) / 3600;
		ans2 = (m1 * 60 + s1 + m2 * 60 + s2) / 60 % 60;
		ans3 = (s1 + s2) % 60;
		cout << ans1 << " " << ans2 << " " << ans3 << endl;
	}
	return 0;
}